﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Method Category - Open API Control Panel
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <fieldset>
        <legend>Method Manage &gt; Category &gt; Add Category</legend>
        <table border="0" cellspacing="0" width="100%">
            <tr>
                <td width="160">
                    Category Code<font color="red">*</font>
                </td>
                <td>
                    <% =Html.TextBox("txtCATEGORY_CD", "", new { @style = "width:250px"})%>
                </td>
            </tr>
            <tr>
                <td width="160">
                    Category Name<font color="red">*</font>
                </td>
                <td>
                    <% =Html.TextBox("txtCATEGORY_NAME", "", new { @style = "width:250px"})%>
                </td>
            </tr>
            <tr>
                <td width="160">
                    Category Desc
                </td>
                <td>
                    <% =Html.TextArea("txtCATEGORY_DESC", "", new { @style = "width:250px",@rows="4" })%>
                </td>
            </tr>
            <tr>
                <td width="160">
                    Category Display Order<font color="red">*</font>
                </td>
                <td>
                    <% =Html.TextBox("txtCATEGORY_ORDER", "", new { @style = "width:80px" })%>
                </td>
            </tr>
            <tr>
                <td width="160">
                    &nbsp;
                </td>
                <td>
                    <input type="button" id="btnMethodCategoryAdd" name="btnMethodCategoryAdd" value="Add Category" />
                    <input type="button" id="btnGoToList" name="btnGoToList" value="Go To List" />
                </td>
            </tr>
        </table>
    </fieldset>
    <script type="text/javascript" language="javascript">

        //json: Submit
        $().ready(function () {
            $("#btnMethodCategoryAdd").click(function () {

                if (confirm('Are you sure submit?')) {

                    var category_cd = $("input[name='txtCATEGORY_CD']").val();
                    var category_name = $("input[name='txtCATEGORY_NAME']").val();
                    var category_desc = $("#txtCATEGORY_DESC").val();
                    var category_order = $("input[name='txtCATEGORY_ORDER']").val();

                    $("input[name='btnMethodCategoryAdd']")[0].disabled = "disabled";
                    $("input[name='btnMethodCategoryAdd']")[0].value = "Add Category...";

                    $.post("/Method/AjaxCategoryAdd?" + new Date(), {
                        Action: "post",
                        category_cd: category_cd,
                        category_name: category_name,
                        category_desc: category_desc,
                        category_order: category_order
                    }, function (result) {
                        if (result.FLAG) {
                            alert(result.DESC);
                            $("input[name='btnMethodCategoryAdd']")[0].disabled = "";
                            $("input[name='btnMethodCategoryAdd']")[0].value = "Add Category";
                            location.href = "/Method/CategoryAdd";
                        }
                        else {
                            alert(result.DESC);
                            $("input[name='btnMethodCategoryAdd']")[0].disabled = "";
                            $("input[name='btnMethodCategoryAdd']")[0].value = "Add Category";
                        }
                    })
                }
            })
        })

        $().ready(function () {
            $("#btnGoToList").click(function () {
                location.href = "/Method/CategoryList";
            })
        })
    </script>
</asp:Content>
